library ieee;
--use work.all;
use work.sram_emu.all;
use work.constants.all;
use ieee.NUMERIC_STD.all;
use ieee.std_logic_1164.all;
--use sram_emu.all;

	-- Add your library and packages declaration here ...

entity c25board_tb is
end c25board_tb;

architecture c25board_arch_rb of c25board_tb is

component c25Board is
port (    
    oscClock50_i    : in    std_logic;
    cpuResetN_i        : in    std_logic;
--    reconfig_i        : in    std_logic;

--    user I/O: buttons+LED    ------------------------------------------------
    buttonN_i        : in    std_logic_vector(4 downto 1);
    ledN_o            : out    std_logic_vector(4 downto 1);

--    Flash    32M x16        ------------------------------------------------
--            ==>    flash_sramData_b(15 downto 0);
--    flashWeN_o        : out    std_logic;
--    flashCsN_o        : out    std_logic;
--    flashOeN_o        : out    std_logic;
--    flashResetN_o        : out    std_logic;
--    flashAdvN_o        : out    std_logic;
--    flashClk_o        : out    std_logic;
--    flashWait_o        : out    std_logic;

--    SSRAM    256k x32    ------------------------------------------------
--            ==>    flash_sramAddr_o(22 downto 2);
    sramOeN_o        : out    std_logic;
    sramCeN_o        : out    std_logic; -- 0
    sramWeN_o        : out    std_logic;
    sramBeN_o        : out    std_logic_vector(3 downto 0); -- 0000 fuer alle bytes
    sramAdscN_o        : out    std_logic; -- 1
    sramClk_o        : out    std_logic;

--    FLASH+SSRAM        ------------------------------------------------
--    flash_sramAddr_o    : out    std_logic_vector(25 downto 1);
    flash_sramAddr_o    : out    std_logic_vector(23 downto 0);
    flash_sramData_b    : inout    std_logic_vector(31 downto 0)

--    DDR SDRAM  4M x16 x4    ------------------------------------------------
--    ddrDqs_b        : inout    std_logic_vector( 1 downto 0);
--    ddrDm_o            : out    std_logic_vector( 1 downto 0);
--    ddrBa_o            : out    std_logic_vector( 1 downto 0);
--    ddrCasN_o        : out    std_logic;
--    ddrCke_o        : out    std_logic;
--    ddrCsN_o        : out    std_logic;
--    ddrRasN_o        : out    std_logic;
--    ddrWeN_o        : out    std_logic;
--    ddrClkP_b        : inout    std_logic;
--    ddrClkN_b        : inout    std_logic;
--    ddrAddr_o        : out    std_logic_vector(12 downto 0);
--    ddrData_b        : inout    std_logic_vector(15 downto 0);

--    HSMC I/O        ------------------------------------------------
--            ==>    naming scheme from "Starter Board" manual
--            ==>    use I/O from daugther board below!!! =>    hc...
--    hsmcSda_b        : inout    std_logic;
--    hsmcScl_b        : inout    std_logic;
--    hsmcTck_i        : in    std_logic;
--    hsmcTms_i        : in    std_logic;
--    hsmcTdi_i        : in    std_logic;
--    hsmcTdo_o        : out    std_logic;
--    hsmcClk0_o        : out    std_logic;
--    hsmcClk0_i        : in    std_logic;
--    hsmcClkP_o        : out    std_logic_vector( 1 to 2);
--    hsmcClkP_i        : in    std_logic_vector( 1 to 2);
--    hsmcClkN_o        : out    std_logic_vector( 1 to 2);
--    hsmcClkN_i        : in    std_logic_vector( 1 to 2);
--    hsmcData_b        : inout    std_logic_vector(19 downto 0);
--    hsmcTxP_b        : inout    std_logic_vector(16 downto 4);
--    hsmcRxP_b        : inout    std_logic_vector(16 downto 4);
--    hsmcTxN_b        : inout    std_logic_vector(16 downto 4);
--    hsmcRxN_b        : inout    std_logic_vector(16 downto 4);

--    LCD touch panel        ------------------------------------------------
--    hcVd_o            : out    std_logic;
--    hcHd_o            : out    std_logic;
--    hcDen_o            : out    std_logic;
--    hcNClk_o        : out    std_logic;
--    hcLcdData_o        : out    std_logic_vector( 7 downto 0);
--    hcGReset_o        : out    std_logic;
--    hcScen_o        : out    std_logic;
--    hcSda_b            : inout    std_logic;
--    hcAdcDClk_o        : out    std_logic;
--    hcAdcDIn_o        : out    std_logic;
--    hcAdcCsN_o        : out    std_logic;
--    hcAdcDOut_i        : in    std_logic;
--    hcAdcPenirqN_i        : in    std_logic;
--    hcAdcBusy_i        : in    std_logic;

--    Audio Codec        ------------------------------------------------
--    hcAudBClk_o        : out    std_logic;
--    hcAudXClk_o        : out    std_logic;
--    hcAudDacData_o        : out    std_logic;
--    hcAudDacLrClk_o        : out    std_logic;
--    hcAudAdcData_i        : in    std_logic;
--    hcAudAdcLrClk_o        : out    std_logic;
--    hcI2cData_b        : inout    std_logic;
--    hcI2cClk_o        : out    std_logic;

--    SD Card Interface    ------------------------------------------------
--    hcSdDat3_b        : inout    std_logic;
--    hcSdCmd_b        : inout    std_logic;
--    hcSdClk_o        : out    std_logic;
--    hcSdDat_b        : inout    std_logic;

--    Ethernet PHY        ------------------------------------------------
--    hcTxClk_i        : in    std_logic;
--    hcTxEn_o        : out    std_logic;
--    hcTxData_o        : out    std_logic_vector( 3 downto 0);
--    hcEthResetN_o        : out    std_logic;
--    hcMdIo_b        : inout    std_logic;
--    hcMdClk_o        : out    std_logic;
--    hcRxClk_o        : in    std_logic;
--    hcRxDv_o        : in    std_logic;
--    hcRxCrs_o        : in    std_logic;
--    hcRxErr_o        : in    std_logic;
--    hcRxCol_o        : in    std_logic;
--    hcRxData_i        : in    std_logic_vector( 3 downto 0);

--    RS232 Serial Interface    ------------------------------------------------
--    hcUartRxData_i        : in    std_logic;
--    hcUartTxData_o        : out    std_logic;

--    PS/2 Interface        ------------------------------------------------
--    hcPS2Clk_b        : inout    std_logic;
--    hcPS2Data_b        : inout    std_logic;

--    Video Decoder Interface    ------------------------------------------------
--    hcTdData_i        : in    std_logic_vector( 7 downto 0);
--    hcTd27MHz_i        : in    std_logic;
--    hcTdReset_o        : out    std_logic;
----    hcI2cData_b        : inout    std_logic;
----    hcI2cClk_o        : out    std_logic;
--    hcTdVs_i        : in    std_logic;
--    hcTdHs_i        : in    std_logic;

--    VGA DAC Interface    ------------------------------------------------
--    hcVgaData_o        : out    std_logic_vector( 9 downto 0);
--    hcVgaBlank_o        : out    std_logic;
--    hcVgaSync_o        : out    std_logic;
--    hcVgaClk_o        : out    std_logic;
--    hcVgaHs_o        : out    std_logic;
--    hcVgaVs_o        : out    std_logic;

--    I2C Serial EEPROM    ------------------------------------------------
--    hcIdI2cClk_o        : out    std_logic;
--    hcIdI2cData_b        : inout    std_logic
    );
end component c25Board;

	-- Stimulus signals - signals mapped to the input and inout ports of tested entity
	signal oscClock50_i : STD_LOGIC := '0';
	signal cpuResetN_i : STD_LOGIC;
	signal buttonN_i : STD_LOGIC_VECTOR(4 downto 1);
	signal flash_sramData_b : STD_LOGIC_VECTOR(31 downto 0);
	-- Observed signals - signals mapped to the output ports of tested entity
	signal ledN_o : STD_LOGIC_VECTOR(4 downto 1);
	signal sramOeN_o : STD_LOGIC;
	signal sramCeN_o : STD_LOGIC;
	signal sramWeN_o : STD_LOGIC;
	signal sramBeN_o : STD_LOGIC_VECTOR(3 downto 0);
	signal sramAdscN_o : STD_LOGIC;
	signal sramClk_o : STD_LOGIC;
	signal flash_sramAddr_o : STD_LOGIC_VECTOR(23 downto 0);
		
	constant cycleTime : time := 10 ns;
	constant resetTime : time := (cycleTime * 2);	
	
begin
	sramBeN_o <= "0000"; -- enable all bytes
	oscClock50_i <= not oscClock50_i after cycleTime / 2; 
	cpuResetN_i <= '0', '1' after resetTime;   
	
	
	UUT: c25board port map (
			oscClock50_i => oscClock50_i,
			cpuResetN_i => cpuResetN_i,
			buttonN_i => buttonN_i,
			ledN_o => ledN_o,
			sramOeN_o => sramOeN_o,
			sramCeN_o => sramCeN_o,
			sramWeN_o => sramWeN_o,
			sramBeN_o => sramBeN_o,
			sramAdscN_o => sramAdscN_o,
			sramClk_o => sramClk_o,
			flash_sramAddr_o => flash_sramAddr_o,
			flash_sramData_b => flash_sramData_b
		);

  	sramC:  	sram generic map(dataWd => 32, addrWd => 24)
			port map(nCS => sramCeN_o, nWE => sramWeN_o, nOE	=> sramOeN_o, addr => flash_sramAddr_o, data => flash_sramData_b);
		  
end c25board_arch_rb;
